package cn.edu.dao.impl;

import cn.edu.dao.IUser;
import cn.edu.entity.User;
import cn.edu.util.UserUtil;

import java.sql.SQLException;
import java.util.List;

/**
 * 所以有查询应该定义成方法.尽量的只书写一次
 */
public class IUserImpl implements IUser {
    public boolean exites(String name) throws Exception {
        String sql = "select * from tb_user where name = ?";
        List list = UserUtil.queryAll(sql,new String[]{name});
        if(list.size()>0){return true;}
        return false;
    }

    @Override
    public boolean isLogon(User user) throws Exception {
        String sql = "select * from tb_user where name=? and password = ?";
        List list = UserUtil.queryAll(sql,new String []{user.getName(),user.getPassword()});
        if(list.size()>0){return true;}
        return false;

    }
}
